﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace WinFormsApp1
{
    public partial class Form2 : Form
    {
        public int orderId = 0;
        public string customerName = null;
        public int goodsKindNum = 0;
        public List<Goods> goodsList = new List<Goods>();
        public Order Order;

        public Form2()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //读取用户输入的数据
            orderId = Convert.ToInt32(this.textBox1.Text);
            customerName = this.textBox2.Text;
            Customer customer = new Customer(customerName);
            goodsKindNum = Convert.ToInt32(this.textBox3.Text);

            for (int i = 0; i < goodsKindNum; i++)
            {
                string goodsName = null;
                int goodsNumber = 0;
                int goodsPrice = 0;

                FormGoods form2_1 = new FormGoods(i);
                form2_1.ShowDialog();


                goodsName = form2_1.goodsName;
                goodsNumber = form2_1.goodsNum;
                goodsPrice = form2_1.goodsPrice;


                Goods goods = new Goods(goodsName, goodsNumber, goodsPrice);
                goodsList.Add(goods);
            }
            OrderDetails orderDetails = new OrderDetails(customer);
            Order order = new Order(orderId, orderDetails);
            Order = order;

            Close();
        }

    }
}